<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%edivi_order_apply}}".
 *
 * @property int $id
 * @property int $edivi_order_id
 * @property int $created_at
 * @property string $req_data
 * @property string $resp
 * @property string $resp_code
 * @property string $resp_data_code
 *
 * @property EdiviCreditOrder $ediviOrder
 */
class EdiviOrderApply extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%edivi_order_apply}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['edivi_order_id', 'created_at'], 'required'],
            [['edivi_order_id', 'created_at'], 'integer'],
            [['req_data', 'resp'], 'string'],
            [['resp_code', 'resp_data_code'], 'string', 'max' => 50],
            [['edivi_order_id'], 'exist', 'skipOnError' => true, 'targetClass' => EdiviCreditOrder::className(), 'targetAttribute' => ['edivi_order_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'edivi_order_id' => Yii::t('app', 'Edivi Order ID'),
            'created_at' => Yii::t('app', 'Created At'),
            'req_data' => Yii::t('app', 'Req Data'),
            'resp' => Yii::t('app', 'Resp'),
            'resp_code' => Yii::t('app', 'Resp Code'),
            'resp_data_code' => Yii::t('app', 'Resp Data Code'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviOrder()
    {
        return $this->hasOne(EdiviCreditOrder::className(), ['id' => 'edivi_order_id']);
    }
}
